
class CopyarticlesController < ApplicationController
before_filter :authorize
    layout "websitearticles3"

def mytest4

  if params[:mymstest]
  @messageres = ""
  @articn = Article.find(params[:article_id]).title
  @websn = Websitesinf.find(params[:id]).name
    @messageres="You have successfully copy website: (<b>"+@websn +"</b>) article: (<b>"+@articn +"</b>) to websites as follows:<br/>"
   params[:mymstest].each do |websid|
   	   	@tagn = Tag.find(:first,:conditions=>"websitesinf_id = "+websid)
   	   	
   	   	if !(@tagn.nil?)
   	         @articobj = Article.find(params[:article_id])
   					   @newcopy = Article.new(:title=>@articobj.title,:synopsis=>@articobj.synopsis,:imageurl=>@articobj.imageurl,:body=>@articobj.body,:tag_id=>@tagn.id,:websitesinf_id=>websid.to_i)
							    
				   @newcopy.save
				   
				   @websn1 = Websitesinf.find(websid).name
				  @messageres= @messageres+"<b>"+ @websn1 +"</b><br/>"				   
				else
   	         @articobj = Article.find(params[:article_id])
   					   @newcopy = Article.new(:title=>@articobj.title,:synopsis=>@articobj.synopsis,:imageurl=>@articobj.imageurl,:body=>@articobj.body,:websitesinf_id=>websid.to_i)
							    
				   @newcopy.save
				   
				   @websn1 = Websitesinf.find(websid).name
				  @messageres= @messageres+"<b>"+ @websn1 +"</b><br/>"						
 #				   @messageres = ""
 #				   @websn1 = Websitesinf.find(websid).name
 #				   flash[:notice]="Sorry copy error, because there is no tags in website <b>"+@websn1+"</b><br/>"	
				end

   end
  end

end


end
